package com.chinemit.cui.utils
{
	import flash.display.DisplayObject;
	import flash.filters.ColorMatrixFilter;
	import flash.filters.GlowFilter;

	public class FilterManager
	{
		
		public function FilterManager()
		{
		}
		
		/**
		 * 设置普通发光样式 
		 * @param dis
		 * 
		 */		
		public function setGlowFilteStyle(dis:DisplayObject,color:uint = 0x4D320E):void{
			var glow:GlowFilter = new GlowFilter(color,1,3,3,8);
			dis.filters = [glow];
		}
		
		/**
		 * 设置鼠标移上发光样式
		 * @param dis
		 * 
		 */		
		public function setGlowFilteMouseOverStyle(dis:DisplayObject,color:uint = 0x4D320E):void{
			var glow:GlowFilter = new GlowFilter(color,1,3,3,8);
			var glow2:GlowFilter = new GlowFilter(0xffffff,0.5,5,5,8);
			dis.filters = [glow,glow2];
		}
		
		
		/**
		 * 设置鼠标移上发光样式
		 * @param dis
		 * 
		 */		
		public function setGlowFilteMouseOverStyle2(dis:DisplayObject,color:uint = 0xffffff,alpha:Number = 0.5):void{
			var glow2:GlowFilter = new GlowFilter(color,alpha,5,5,8,1,true);
			dis.filters = [glow2];
		}
		
		
		public function turnGrey(target:DisplayObject):void
		{
			if(!target){
				return;
			}
			var matrix:Array = new Array();
			matrix = matrix.concat([0.33, 0.33, 0.33, 0, 0]);// red
			matrix = matrix.concat([0.33, 0.33, 0.33, 0, 0]);// green
			matrix = matrix.concat([0.33, 0.33, 0.33, 0, 0]);// blue
			matrix = matrix.concat([0, 0, 0, 1, 0]);// alpha
			var filters:Array = target.filters;
			filters.push(new ColorMatrixFilter(matrix));
			target.filters = filters;
		}
		
		private static var instance:FilterManager;
		public static function getInstance():FilterManager{
			if(!instance){
				instance = new FilterManager();
			}
			return instance;
		}
	}
}